package org.framework.funtionNode.functionNode;

import java.io.FilenameFilter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.quickbundle.base.beans.factory.RmBeanFactory;
import org.quickbundle.base.web.page.RmPageVo;
import org.quickbundle.config.RmConfig;
import org.quickbundle.orgauth.IOrgauthConstants;
import org.quickbundle.orgauth.cache.RmAuthorizeCache;
import org.quickbundle.orgauth.custom.impl.RmCustomOrgService;
import org.quickbundle.orgauth.rmauthorize.vo.RmAuthorizeVo;
import org.quickbundle.orgauth.rmauthorizeresource.service.IRmAuthorizeResourceService;
import org.quickbundle.orgauth.rmauthorizeresource.vo.RmAuthorizeResourceVo;
import org.quickbundle.orgauth.rmfunctionnode.service.IRmFunctionNodeService;
import org.quickbundle.orgauth.rmfunctionnode.util.IRmFunctionNodeConstants;
import org.quickbundle.orgauth.rmfunctionnode.vo.RmFunctionNodeVo;
import org.quickbundle.orgauth.rmparty.service.IRmPartyService;
import org.quickbundle.orgauth.rmparty.util.IRmPartyConstants;
import org.quickbundle.orgauth.rmpartyrelation.service.impl.RmPartyRelationService;
import org.quickbundle.orgauth.rmpartyrelation.vo.RmPartyRelationVo;
import org.quickbundle.orgauth.rmrole.service.IRmRoleService;
import org.quickbundle.orgauth.rmuser.service.IRmUserService;
import org.quickbundle.orgauth.rmuser.vo.RmUserVo;
import org.quickbundle.orgauth.util.impl.RmOrgService;
import org.quickbundle.project.IGlobalConstants;
import org.quickbundle.project.RmGlobalReference;
import org.quickbundle.project.RmProjectHelper;
import org.quickbundle.project.cache.RmSqlCountCache;
import org.quickbundle.project.common.vo.RmCommonVo;
import org.quickbundle.tools.helper.RmJspHelper;
import org.quickbundle.tools.helper.RmPopulateHelper;
import org.quickbundle.tools.helper.RmSqlHelper;
import org.quickbundle.tools.helper.RmStringHelper;
import org.quickbundle.tools.helper.RmVoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.dfhc.ISystemConstant;
import com.dfhc.pub.concurrencycontrol.RequestConcurrentRoute;
import com.dfhc.pub.service.PickMenuLinkInPageService;
import com.dfhc.pub.service.PubParamService;
import com.dfhc.rm.user.IUserConstants;
import com.dfhc.rm.user.service.UserService;
import com.dfhc.rm.user.vo.UserVo;
import com.dfhc.util.CommentFileFilter;
import com.dfhc.util.FileOperateHelper;
import com.dfhc.util.HttpClientUtil;
import com.dfhc.util.JspHelper;
import com.dfhc.util.StringHelper;

/**
 * @author ASUS 会员列表(例子)
 */
@Controller
@RequestMapping(value = "/rmFunctionNode")
public class RmFunctionNodeController implements IRmFunctionNodeConstants {

	/*
	 * 註解
	 * 
	 */

	private static final String PICK_MENU_SERVER_NAME = "localhost";
	@Autowired
	private IRmFunctionNodeService iRmFunctionNodeService;
	@Autowired
	private IRmPartyService iRmPartyService;
	@Autowired
	private IRmAuthorizeResourceService iRmAuthorizeResourceService;
	@Autowired
	private PickMenuLinkInPageService pickMenuLinkInPageService;

	/*
	 * 查询list
	 */
	@RequestMapping(value = "")
	public String list(Model model, HttpServletRequest request) throws UnsupportedEncodingException {
		Map<String, Object> dataMap = new HashMap<String, Object>();
		request.setAttribute(REQUEST_QUERY_CONDITION, "");
		String queryCondition = getQueryCondition(request); // 从request中获得查询条件
		RmPageVo pageVo = RmJspHelper.transctPageVo(request, getCount(queryCondition));
		String orderStr = RmJspHelper.getOrderStr(request); // 得到排序信息
		List<RmFunctionNodeVo> beans = iRmFunctionNodeService.queryByCondition(queryCondition, orderStr, pageVo.getStartIndex(), pageVo.getPageSize()); // 按条件查询全部,带排序
		// 如果采用下边这句，就是不带翻页的，同时需要删掉list页面的page.jsp相关语句
		// beans = service.queryByCondition(queryCondition, orderStr);
		// //查询全部,带排序
		int totalNum = getCount(queryCondition);
		dataMap.put(ISystemConstant.RECORDS_TOTAL, totalNum);
		dataMap.put(ISystemConstant.RECORDS_FILTERED, totalNum);
		RmJspHelper.saveOrderStr(orderStr, request); // 保存排序信息
		request.setAttribute(REQUEST_QUERY_CONDITION, queryCondition);
		request.setAttribute(REQUEST_BEANS, beans); // 把结果集放入request
		request.setAttribute(REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request)); // 回写表单
		return "/qb5activiti/rmfunctionnode/listNewRmFunctionNode";
	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "/functionNodelist")
	public String functionNodelist(Model model, HttpServletRequest request) throws UnsupportedEncodingException {
		return "/qb5activiti/rmfunctionnode/newFunctionNode1";

	}

	/**
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "/insertRmFunctionNodeByHx")
	public String insertRmFunctionNodeByHx(Model model, HttpServletRequest request) throws UnsupportedEncodingException {
		return "/qb5activiti/rmfunctionnode/insertRmFunctionNodeByHx";

	}

	/**
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */
	@RequestMapping(value = "newAddToHX")
	public String newAddToHX(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		String id = request.getParameter("id");
		String parent_total_code = request.getParameter("parent_total_code");
		request.setAttribute("id", id);
		request.setAttribute("parent_total_code", parent_total_code);
		String default_total_code = "";
		if(RmStringHelper.checkNotEmpty(parent_total_code)) {
			List<RmCommonVo> lvo = RmProjectHelper.getCommonServiceInstance().doQuery("select max(TOTAL_CODE) max_total_code from RM_FUNCTION_NODE where TOTAL_CODE like '" + parent_total_code + "%' and length(TOTAL_CODE) = " + (parent_total_code.length()+RmConfig.getSingleton().getDefaultTreeCodeFirst().length()));
			if(lvo.size() > 0) {
				String max_total_code = lvo.get(0).getString("max_total_code");
				if(max_total_code != null && max_total_code.length() > 0) {
					String temp_code = max_total_code.substring(max_total_code.length() - RmConfig.getSingleton().getDefaultTreeCodeFirst().length());
					long nextLasePhaseCode = Long.valueOf(temp_code) + 1;
					default_total_code = max_total_code.substring(0, max_total_code.length() - RmConfig.getSingleton().getDefaultTreeCodeFirst().length()) + nextLasePhaseCode;				
				} else {
					default_total_code = parent_total_code + RmConfig.getSingleton().getDefaultTreeCodeFirst();
				}
			}
		} else {
			default_total_code = RmConfig.getSingleton().getDefaultTreeCodeFirst();
		}
		request.setAttribute("default_total_code", default_total_code);
		RmFunctionNodeVo resultVo = null;
		boolean isModify = false;  //定义变量,标识本页面是否修改(或者新增)
		if(request.getParameter("isModify") != null) {  //如果从request获得参数"isModify"不为空
			isModify = true;  //赋值isModify为true
	  		if(request.getAttribute(IRmFunctionNodeConstants.REQUEST_BEAN) != null) {  //如果request中取出的bean不为空
	  			resultVo = (RmFunctionNodeVo)request.getAttribute(IRmFunctionNodeConstants.REQUEST_BEAN);  //从request中取出vo, 赋值给resultVo
	  		}
		}
		request.setAttribute("isModify", isModify);
		request.setAttribute("resultVo", resultVo);
		return "/qb5activiti/rmfunctionnode/insertRmFunctionNodeByHx";

	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */
	@RequestMapping(value = "/showPage")
	public String showPage(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		detailAjaxList(model, request, response);
		return "/qb5activiti/rmfunctionnode/insertRmFunctionNodeByHx";

	}

	/**
	 * 得到缓存中查询条件对应的count(*)记录数，如返回-1则执行查询
	 * 
	 * @param queryCondition
	 * @return
	 */
	protected int getCount(String queryCondition) {
		int count = RmSqlCountCache.getCount(TABLE_NAME, queryCondition);
		if (count < 0) {
			count = iRmFunctionNodeService.getRecordCount(queryCondition);
			RmSqlCountCache.putCount(TABLE_NAME, queryCondition, count);
		}
		return count;
	}

	/**
	 * ajax 请求列表数据
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "ajaxList", produces = "application/json")
	@ResponseBody
	public Map<String, Object> ajaxList(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		boolean bLock = false;
		Map map = new HashMap();
		Enumeration paramNames = request.getParameterNames();
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();

			String[] paramValues = request.getParameterValues(paramName);
			if (paramValues.length == 1) {
				String paramValue = paramValues[0];
				if (paramValue.length() != 0) {
					map.put(paramName, paramValue);
				}
			}
		}

		Set<Map.Entry<String, String>> set = map.entrySet();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			// 获取开始记录数
			String queryCondition = getQueryCondition(request); // 从request中获得查询条件
			RmPageVo pageVo = RmJspHelper.transctPageVo(request, getCount(queryCondition));
			String orderStr = RmJspHelper.getOrderStr(request); // 得到排序信息
			List<RmFunctionNodeVo> beans = iRmFunctionNodeService.queryByCondition(queryCondition, orderStr, pageVo.getStartIndex(), pageVo.getPageSize()); // 按条件查询全部,带排序
			// 翻译状态码
			int totalNum = pageVo.getRecordCount();
			dataMap.put(ISystemConstant.RECORDS_TOTAL, totalNum);
			dataMap.put(ISystemConstant.RECORDS_FILTERED, totalNum);
			dataMap.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
			dataMap.put(ISystemConstant.PAGE_DRAW, request.getParameter(ISystemConstant.PAGE_DRAW));
			// "recordsTotal"
			/*
			 * dataMap.put(ISystemConstant.RECORDS_TOTAL,totalNum);
			 * dataMap.put(ISystemConstant.RECORDS_FILTERED, totalNum);
			 */
			request.setAttribute(REQUEST_QUERY_CONDITION, queryCondition);
			request.setAttribute(REQUEST_BEANS, beans); // 把结果集放入request
			request.setAttribute(REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request));
			dataMap.put(ISystemConstant.DATA, beans);
			return dataMap;
		} catch (Exception e) {
			e.printStackTrace();
			RmProjectHelper.logInf(StringHelper.exceptionToString(e));
			dataMap.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
			dataMap.put(ISystemConstant.AJAX_MESSAGE, "查询失败!");
			return dataMap;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 功能: 从request中获得查询条件
	 *
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	protected String getQueryCondition(HttpServletRequest request) throws UnsupportedEncodingException {
		String queryCondition = null;
		String name = request.getParameter("name");
		if (request.getAttribute(REQUEST_QUERY_CONDITION) != null) { // 如果request.getAttribute中有，就不取request.getParameter
			queryCondition = request.getAttribute(REQUEST_QUERY_CONDITION).toString();
		} else {
			List<String> lQuery = new ArrayList<String>();

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".node_type", request.getParameter("node_type"), RmSqlHelper.TYPE_CUSTOM, "='", "'"));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".function_property", request.getParameter("function_property"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".name", request.getParameter("name"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".enable_status", request.getParameter("enable_status"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".total_code", request.getParameter("total_code"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".order_code", request.getParameter("order_code"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".funcnode_authorize_type", request.getParameter("funcnode_authorize_type"), RmSqlHelper.TYPE_CUSTOM, "='", "'"));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".description", request.getParameter("description"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".data_value", request.getParameter("data_value"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".pattern_value", request.getParameter("pattern_value"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".is_leaf", request.getParameter("is_leaf"), RmSqlHelper.TYPE_CUSTOM, "='", "'"));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".icon", request.getParameter("icon"), RmSqlHelper.TYPE_CHAR_LIKE));

			lQuery.add(RmSqlHelper.buildQueryStr(TABLE_NAME + ".help_name", request.getParameter("help_name"), RmSqlHelper.TYPE_CHAR_LIKE));

			queryCondition = RmSqlHelper.appendQueryStr(lQuery.toArray(new String[0]));
		}
		return queryCondition;
	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */
	@RequestMapping(value = "detail")
	public String detail(Model model, HttpServletRequest request) throws IOException {
		RmFunctionNodeVo bean = iRmFunctionNodeService.find(request.getParameter(REQUEST_ID)); // 通过id获取vo
		String total_code = bean.getTotal_code();
		List<RmFunctionNodeVo> beanList = iRmFunctionNodeService.findByTotalCode(total_code + "___", ISystemConstant.DICTIONARY_FUNCTION_PROPERTY_3);
		request.setAttribute(REQUEST_BEAN, bean); // 把vo放入request
		request.setAttribute(REQUEST_BEAN_LIST, beanList); // 把选中的业内连接放入request
		request.setAttribute("IS_UPDATE", "TRUE");
		// 获取jsp根目录
		String jspRootPath = FileOperateHelper.getProjectPath(request);
		jspRootPath = jspRootPath + ISystemConstant.JSP_RELA_ROOT_PATH;

		request.setAttribute("jspRootPath", jspRootPath);
		// String string = RmGlobalReference.get("dictionaryType",
		// "dictionaryKey");
		String regEx = RmGlobalReference.get(ISystemConstant.REGULAR_EX, "01");
		/* String regEx="form.action=\"(.+?);" ; */
		String menuUrl = request.getParameter("data_value");
		ArrayList<String> arrayList = new ArrayList<>();
		if (!StringHelper.isEmpty(menuUrl)) {
			menuUrl = request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath() + menuUrl;

			HashMap<String, String> hashMap = new HashMap<>();
			hashMap.put("Host", PICK_MENU_SERVER_NAME + ":" + getWebServerPort());
			hashMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0");
			hashMap.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
			hashMap.put("Accept-Encoding", "gzip, deflate");
			hashMap.put("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
			hashMap.put("Connection", "keep-alive");
			hashMap.put("Referer", request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath());
			hashMap.put("Cookie", "JSESSIONID=" + request.getSession().getId());
			String htmlPage = HttpClientUtil.get(menuUrl, hashMap);

			Pattern pattern = Pattern.compile(regEx);
			Matcher matcher = pattern.matcher(htmlPage.toString());

			String contextPath = request.getContextPath();
			while (matcher.find()) {
				String oldlink = "";
				for (int i = 1; i <= matcher.groupCount(); i++) {
					oldlink = matcher.group(i);
					if (!StringHelper.isEmpty(oldlink)) {
						break;
					}
				}
				if (!StringHelper.isEmpty(oldlink) && StringHelper.findStrNum(oldlink, "/") > 0) {
					String link = oldlink.replace(contextPath, "");
					link = link.replace("+", "");
					link = link.replace("\"", "");
					link = link.replace(" ", "");
					arrayList.add(link);
				}
			}
			Iterator<String> iterator = arrayList.iterator();
			while (iterator.hasNext()) {
				String next = iterator.next();
				for (int i = 0; i < beanList.size(); i++) {
					if (beanList.get(i).getData_value().equals(next)) {
						iterator.remove();
						break;
					}
				}
			}
		}
		request.setAttribute("unchecked", arrayList);

		if (RM_YES.equals(request.getParameter(REQUEST_IS_READ_ONLY))) {
			request.setAttribute(REQUEST_IS_READ_ONLY, request.getParameter(REQUEST_IS_READ_ONLY));
		}
		return "/qb5activiti/rmfunctionnode/detailNewRmFunctionNode";
	}

	/**
	 * ajax 请求列表数据
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "detailAjaxList")
	@ResponseBody
	public Map<String, Object> detailAjaxList(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		boolean bLock = false;
		Map map = new HashMap();
		Enumeration paramNames = request.getParameterNames();
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();

			String[] paramValues = request.getParameterValues(paramName);
			if (paramValues.length == 1) {
				String paramValue = paramValues[0];
				if (paramValue.length() != 0) {
					map.put(paramName, paramValue);
				}
			}
		}

		Set<Map.Entry<String, String>> set = map.entrySet();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			RmFunctionNodeVo bean = iRmFunctionNodeService.find(request.getParameter(REQUEST_ID)); // 通过id获取vo
			String total_code = bean.getTotal_code();
			List<RmFunctionNodeVo> beanList = iRmFunctionNodeService.findByTotalCode(total_code + "___", ISystemConstant.DICTIONARY_FUNCTION_PROPERTY_3);
			request.setAttribute(REQUEST_BEAN, bean); // 把vo放入request
			request.setAttribute(REQUEST_BEAN_LIST, beanList); // 把选中的业内连接放入request
			request.setAttribute("IS_UPDATE", "TRUE");
			// 获取jsp根目录
			String jspRootPath = FileOperateHelper.getProjectPath(request);
			jspRootPath = jspRootPath + ISystemConstant.JSP_RELA_ROOT_PATH;

			request.setAttribute("jspRootPath", jspRootPath);
			// String string = RmGlobalReference.get("dictionaryType",
			// "dictionaryKey");
			String regEx = RmGlobalReference.get(ISystemConstant.REGULAR_EX, "01");
			/* String regEx="form.action=\"(.+?);" ; */
			String menuUrl = request.getParameter("data_value");
			ArrayList<String> arrayList = new ArrayList<>();
			if (!StringHelper.isEmpty(menuUrl)) {
				menuUrl = request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath() + menuUrl;

				HashMap<String, String> hashMap = new HashMap<>();
				hashMap.put("Host", PICK_MENU_SERVER_NAME + ":" + getWebServerPort());
				hashMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0");
				hashMap.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
				hashMap.put("Accept-Encoding", "gzip, deflate");
				hashMap.put("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
				hashMap.put("Connection", "keep-alive");
				hashMap.put("Referer", request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath());
				hashMap.put("Cookie", "JSESSIONID=" + request.getSession().getId());
				String htmlPage = HttpClientUtil.get(menuUrl, hashMap);

				Pattern pattern = Pattern.compile(regEx);
				Matcher matcher = pattern.matcher(htmlPage.toString());

				String contextPath = request.getContextPath();
				while (matcher.find()) {
					String oldlink = "";
					for (int i = 1; i <= matcher.groupCount(); i++) {
						oldlink = matcher.group(i);
						if (!StringHelper.isEmpty(oldlink)) {
							break;
						}
					}
					if (!StringHelper.isEmpty(oldlink) && StringHelper.findStrNum(oldlink, "/") > 0) {
						String link = oldlink.replace(contextPath, "");
						link = link.replace("+", "");
						link = link.replace("\"", "");
						link = link.replace(" ", "");
						arrayList.add(link);
					}
				}
				Iterator<String> iterator = arrayList.iterator();
				while (iterator.hasNext()) {
					String next = iterator.next();
					for (int i = 0; i < beanList.size(); i++) {
						if (beanList.get(i).getData_value().equals(next)) {
							iterator.remove();
							break;
						}
					}
				}
			}
			request.setAttribute("unchecked", arrayList);

			if (RM_YES.equals(request.getParameter(REQUEST_IS_READ_ONLY))) {
				request.setAttribute(REQUEST_IS_READ_ONLY, request.getParameter(REQUEST_IS_READ_ONLY));
			}
			/* request.setAttribute(REQUEST_QUERY_CONDITION, queryCondition); */
			request.setAttribute(REQUEST_BEANS, bean); // 把结果集放入request
			request.setAttribute(REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request));
			dataMap.put(ISystemConstant.DATA, bean);
			return dataMap;
		} catch (Exception e) {
			e.printStackTrace();
			RmProjectHelper.logInf(StringHelper.exceptionToString(e));
			dataMap.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
			dataMap.put(ISystemConstant.AJAX_MESSAGE, "查询失败!");
			return dataMap;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 获取webserver端口
	 * 
	 * @return
	 */
	private String getWebServerPort() {
		return RmGlobalReference.get(ISystemConstant.DICTIONARY_WEBSERVER_CONFIG, ISystemConstant.DICTIONARY_WEBSERVER_PORT);
	}

	/**
	 * ajax 请求列表数据
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "rmAuthorizeAjaxList")
	@ResponseBody
	public Map<String, Object> rmAuthorizeAjaxList(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		boolean bLock = false;
		Map map = new HashMap();
		Enumeration paramNames = request.getParameterNames();
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();

			String[] paramValues = request.getParameterValues(paramName);
			if (paramValues.length == 1) {
				String paramValue = paramValues[0];
				if (paramValue.length() != 0) {
					map.put(paramName, paramValue);
				}
			}
		}

		Set<Map.Entry<String, String>> set = map.entrySet();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			List list = new ArrayList();
			String party_id = request.getParameter("party_id");
			String bs_keyword = request.getParameter("bs_keyword");
			String old_resource_id = request.getParameter("old_resource_id");
			RmAuthorizeVo authorize = RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword);
			List<RmCommonVo> lvo = RmProjectHelper.getCommonServiceInstance().doQuery(
					"SELECT A.*, B.NAME AS RM_DISPLAY_COLUMN FROM RM_AUTHORIZE_RESOURCE_RECORD A JOIN RM_PARTY B ON A.PARTY_ID = B.ID join RM_AUTHORIZE_RESOURCE C ON A.AUTHORIZE_RESOURCE_ID=C.ID WHERE C.AUTHORIZE_ID=" + authorize.getId() + " and C.OLD_RESOURCE_ID='" + old_resource_id + "'");
			/* request.setAttribute(REQUEST_QUERY_CONDITION, queryCondition); */
			list.add(party_id);
			list.add(bs_keyword);
			list.add(old_resource_id);
			int totalNum = lvo.size();
			dataMap.put(ISystemConstant.RECORDS_TOTAL, totalNum);
			dataMap.put(ISystemConstant.RECORDS_FILTERED, totalNum);
			request.setAttribute("list", list);
			request.setAttribute(REQUEST_BEANS, lvo); // 把结果集放入request
			request.setAttribute(REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request));
			dataMap.put(ISystemConstant.DATA, lvo);
			return dataMap;
		} catch (Exception e) {
			e.printStackTrace();
			RmProjectHelper.logInf(StringHelper.exceptionToString(e));
			dataMap.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
			dataMap.put(ISystemConstant.AJAX_MESSAGE, "查询失败!");
			return dataMap;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	@RequestMapping(value = "/insertRmFunctionNode")
	public String insertRmFunctionNode(Model model, HttpServletRequest request) throws IOException {
		detailAjaxList(model, request, null);
		return "/qb5activiti/rmfunctionnode/insertRmFunctionNode";

	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	@RequestMapping(value = "/deleteToHX")
	@ResponseBody
	public Map<String, Object> deleteToHX(HttpServletRequest request) {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			Map<String, Object> result = new HashMap<String, Object>();
			try {
				if ( request.getParameter("total_code") != null|| !request.getParameter("total_code").isEmpty() ) {
					iRmFunctionNodeService.deleteFunctionNode(request.getParameter(REQUEST_ID), request.getParameter("total_code"));
				} else {
					result.put(ISystemConstant.AJAX_MESSAGE, "删除用户失败!");
				}
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
				result.put(ISystemConstant.AJAX_MESSAGE, "删除用户成功!");
			} catch (Exception e) {
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);

			}
			return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	@RequestMapping(value = "/achieve")
	public String achieve(Model model, HttpServletRequest request) throws IOException {
		String[] names = request.getParameterValues("names");
		iRmFunctionNodeService.insertSelfAndLinkInPage(names, request);
		return "/qb5activiti/rmfunctionnode/newFunctionNode1";

	}

	/**
	 * 简单查询，分页显示，支持表单回写
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	@RequestMapping(value = "/newInitRmResource")
	public String newInitRmResource(Model model, HttpServletRequest request) throws IOException {
		String bs_keyword = request.getParameter("bs_keyword");
		String old_resource_id = request.getParameter("old_resource_id");
		List<RmCommonVo> listVo = RmProjectHelper.getCommonServiceInstance().doQuery("select AR.id,AR.default_access,AR.name  from RM_AUTHORIZE_RESOURCE AR join RM_AUTHORIZE  A on AR.AUTHORIZE_ID=A.Id where A.BS_KEYWORD = '" + bs_keyword + "'AND AR.OLD_RESOURCE_ID = '" + old_resource_id + "'");
		RmCommonVo bean = null;
		if (listVo.size() > 0) {
			bean = listVo.get(0);
			bean.put("old_resource_id", old_resource_id);
			bean.put("bs_keyword", bs_keyword);
		}
		request.setAttribute("bs_keyword", bs_keyword);
		request.setAttribute("old_resource_id", old_resource_id);
		request.setAttribute("bean", bean);
		return "/qb5activiti/rmfunctionnode/newInitRmResource";

	}

	/**
	 * 删除单条记录
	 * 
	 * @param request
	 *            http请求对象
	 * @return 返回Ajax应答实体对象
	 */
	@RequestMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> delete(HttpServletRequest request) {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			Map<String, Object> result = new HashMap<String, Object>();
			try {
				String party_id = request.getParameter("party_id");
				String bs_keyword = request.getParameter("bs_keyword");
				String[] authorize_resource_ids = request.getParameter("authorize_resource_ids").split(",");
				int count = iRmPartyService.deleteRm_authorize_resource_record(party_id, authorize_resource_ids);
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
				result.put(ISystemConstant.AJAX_MESSAGE, "删除用户成功!");
			} catch (Exception e) {
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
				result.put(ISystemConstant.AJAX_MESSAGE, "删除用户失败!");
			}
			return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	/*@RequestMapping(value = "/updateDefaultAccess")
	public String updateDefaultAccess(Model model, HttpServletRequest request) throws IOException {
		String bs_keyword = request.getParameter("bs_keyword");
		String old_resource_id = request.getParameter("old_resource_id");
		RmAuthorizeResourceVo vo = new RmAuthorizeResourceVo();
		RmPopulateHelper.populate(vo, request); // 从request中注值进去vo
		RmVoHelper.markCreateStamp(request, vo); // 打创建时间,IP戳
		vo.setAuthorize_id(RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword).getId());
		vo.setOld_resource_id(old_resource_id);
		vo.setDefault_is_affix_data("0");
		vo.setDefault_access_type("11");
		vo.setDefault_is_recursive("1");
		List lResource = iRmAuthorizeResourceService.queryByCondition("AUTHORIZE_ID='" + RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword).getId() + "' AND OLD_RESOURCE_ID='" + old_resource_id + "'", null);
		if (lResource.size() > 0) {
			RmAuthorizeResourceVo resourceVo = (RmAuthorizeResourceVo) lResource.get(0);
			vo.setId(resourceVo.getId());
			iRmAuthorizeResourceService.update(vo); // 更新
		} else {
			// String id =
			iRmAuthorizeResourceService.insert(vo); // 插入单条记录
		}
		request.setAttribute("bs_keyword", bs_keyword);
		request.setAttribute("old_resource_id", old_resource_id);
		return "/qb5activiti/rmfunctionnode/newInitRmResource";

	}*/
	@RequestMapping(value = "/updateDefaultAccess", produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> updateDefaultAccess(HttpServletRequest request) {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			Map<String, Object> result = new HashMap<String, Object>();
			try {
				String bs_keyword = request.getParameter("bs_keyword");
				String old_resource_id = request.getParameter("old_resource_id");
				RmAuthorizeResourceVo vo = new RmAuthorizeResourceVo();
				RmPopulateHelper.populate(vo, request); // 从request中注值进去vo
				RmVoHelper.markCreateStamp(request, vo); // 打创建时间,IP戳
				vo.setAuthorize_id(RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword).getId());
				vo.setOld_resource_id(old_resource_id);
				vo.setDefault_is_affix_data("0");
				vo.setDefault_access_type("11");
				vo.setDefault_is_recursive("1");
				List lResource = iRmAuthorizeResourceService.queryByCondition("AUTHORIZE_ID='" + RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword).getId() + "' AND OLD_RESOURCE_ID='" + old_resource_id + "'", null);
				if (lResource.size() > 0) {
					RmAuthorizeResourceVo resourceVo = (RmAuthorizeResourceVo) lResource.get(0);
					vo.setId(resourceVo.getId());
					iRmAuthorizeResourceService.update(vo); // 更新
				} else {
					// String id =
					iRmAuthorizeResourceService.insert(vo); // 插入单条记录
				}
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
				result.put(ISystemConstant.AJAX_MESSAGE, "受控成功!");
			} catch (Exception e) {
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
				result.put(ISystemConstant.AJAX_MESSAGE, "受控失败!");
			}
			return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * ajax 请求列表数据
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/dealWithUrl")
	@ResponseBody
	public Map<String, Object> dealWithUrl(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		boolean bLock = false;
		Map map = new HashMap();
		Enumeration paramNames = request.getParameterNames();
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();

			String[] paramValues = request.getParameterValues(paramName);
			if (paramValues.length == 1) {
				String paramValue = paramValues[0];
				if (paramValue.length() != 0) {
					map.put(paramName, paramValue);
				}
			}
		}

		Set<Map.Entry<String, String>> set = map.entrySet();
		// Map<String, Object> dataMap = new HashMap<String, Object>();
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			String menuUrl = request.getParameter("menuUrl");

			String regEx = RmGlobalReference.get(ISystemConstant.REGULAR_EX, "01");

			menuUrl = request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath() + menuUrl;

			HashMap<String, String> hashMap = new HashMap<>();
			hashMap.put("Host", PICK_MENU_SERVER_NAME + ":" + getWebServerPort());
			hashMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0");
			hashMap.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
			hashMap.put("Accept-Encoding", "gzip, deflate");
			hashMap.put("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
			hashMap.put("Connection", "keep-alive");
			hashMap.put("Referer", request.getScheme() + "://" + PICK_MENU_SERVER_NAME + ":" + getWebServerPort() + request.getContextPath());
			hashMap.put("Cookie", "JSESSIONID=" + request.getSession().getId());
			String htmlPage = HttpClientUtil.get(menuUrl, hashMap);

			Pattern pattern = Pattern.compile(regEx);
			Matcher matcher = pattern.matcher(htmlPage.toString());
			ArrayList<String> arrayList = new ArrayList<>();

			while (matcher.find()) {
				String oldlink = "";
				for (int i = 1; i <= matcher.groupCount(); i++) {
					if (matcher.group(i) != null) {
						oldlink = matcher.group(i);

						break;
					}
				}
				String contextPath = request.getContextPath();

				String link = StringHelper.replaceAll(oldlink, contextPath, "").toString();

				link = link.replace("+", "");
				link = link.replace("\"", "");
				link = link.replace(" ", "");

				arrayList.add(link);
			}

			response.setContentType("text/text;charset=utf-8");
			response.setHeader("cache-control", "no-cache");
			OutputStream stream = response.getOutputStream();
			String data = JSON.toJSONString(arrayList);

			stream.write(data.getBytes("UTF-8"));
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			RmProjectHelper.logInf(StringHelper.exceptionToString(e));
			return null;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * ajax 请求列表数据
	 * 
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/importFunctionLink")
	@ResponseBody
	public Map<String, Object> importFunctionLink(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			String jspPath = request.getParameter("jspPath");
			String totalCode = request.getParameter("total_Code");
			response.setContentType("text/text;charset=utf-8");
			response.setHeader("cache-control", "no-cache");
			OutputStream stream = response.getOutputStream();

			if (StringHelper.isEmpty(totalCode) || StringHelper.isEmpty(jspPath)) {
				stream.write("缺少参数".getBytes("UTF-8"));
				return null;
			}
			List<String> arrayList = new ArrayList<>();

			FilenameFilter fileFilter = new CommentFileFilter(".*.jsp");
			List<String> files = FileOperateHelper.searchFile(jspPath, fileFilter);
			List<String> menuCodeList = new ArrayList<String>();
			menuCodeList.add(totalCode);
			pickMenuLinkInPageService.init();
			pickMenuLinkInPageService.clearMenuList();
			// 循环提取文件
			if (files != null) {
				for (String fileName : files) {
					pickMenuLinkInPageService.pickLinkFromFile(fileName, menuCodeList);
				}
			}

			List<String> menuLinks = pickMenuLinkInPageService.getMenuLinkList();

			// 提出已经存在的链接,并加工
			for (String menuLink : menuLinks) {
				menuLink = pickMenuLinkInPageService.fixMenuLink(menuLink);
				arrayList.add(menuLink);

			}
			String data = JSON.toJSONString(arrayList);

			stream.write(data.getBytes("UTF-8"));
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			RmProjectHelper.logInf(StringHelper.exceptionToString(e));
			return null;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */
	@RequestMapping(value = "/insert")
	@ResponseBody
	public Map<String, Object> insert(Model model, HttpServletRequest request) throws IOException {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			Map<String, Object> result = new HashMap<String, Object>();
			try {
				String[] names = request.getParameterValues("names");
				iRmFunctionNodeService.insertSelfAndLinkInPage(names, request);
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
				result.put(ISystemConstant.AJAX_MESSAGE, "新增成功!");
			} catch (Exception e) {
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
				result.put(ISystemConstant.AJAX_MESSAGE, "新增失败!");
			}
			return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
		/* return "/qb5activiti/rmfunctionnode/newFunctionNode1"; */

	}

	/**
	 * 
	 * @param model
	 *            模型
	 * @param request
	 *            http请求对象
	 * @return 跳转的列表jsp
	 * @throws IOException
	 */

	@RequestMapping(value = "/update")
	@ResponseBody
	public Map<String, Object> update(Model model, HttpServletRequest request) throws IOException {
		boolean bLock = false;
		try {
		bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			String datevalue = request.getParameter("data_value");
		String[] names = request.getParameterValues("names");
	    String total_code = request.getParameter("total_code");	
	    iRmFunctionNodeService.deleteByTotalCode(total_code+"___",ISystemConstant.DICTIONARY_FUNCTION_PROPERTY_3);
	    
    	RmFunctionNodeVo vo =iRmFunctionNodeService.find(request.getParameter("id")) ;
        RmPopulateHelper.populate(vo, request);  //从request中注值进去vo
        RmVoHelper.markModifyStamp(request,vo);  //打修改时间,IP戳
        int count = iRmFunctionNodeService.update(vo);  //更新单条记录
        request.setAttribute(EXECUTE_ROW_COUNT, count);  //sql影响的行数放入request属性*/
        if(names!=null && names.length>0){
	        for (int i = 0,val=100; i < names.length; i++,val++) {
				val=getNewTotalCode(total_code, val);				
				vo = new RmFunctionNodeVo();
				vo.setNode_type("2");
				vo.setFunction_property("3");
				vo.setName(names[i]);
				vo.setEnable_status("1");
				vo.setTotal_code(total_code+val);
				vo.setFuncnode_authorize_type("1");
				vo.setData_value(names[i]);
				vo.setIs_leaf("1");
				vo.setUsable_status("1");
				RmVoHelper.markCreateStamp(request,vo); 
				String id = iRmFunctionNodeService.insert(vo);  //插入单条记录
		        request.setAttribute(IGlobalConstants.INSERT_FORM_ID, id);  //新增记录的id放入request属性
			}
        }
        result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
		result.put(ISystemConstant.AJAX_MESSAGE, "新增成功!");
		} catch (Exception e) {
			result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
			result.put(ISystemConstant.AJAX_MESSAGE, "新增失败!");
		}
		return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}

	/**
	 * 获取新的菜单码
	 * 
	 * @param total_code
	 * @param val
	 * @return
	 */
	private int getNewTotalCode(String total_code, int val) {

		String sql = "select count(*) from rm_function_node where total_code='%s'";
		while (true) {
			if (RmProjectHelper.getCommonServiceInstance().doQueryForInt(String.format(sql, total_code + val)) == 0) {
				break;
			}
			val++;
		}
		return val;
	}

	/**
	 * 删除单条记录
	 * 
	 * @param request
	 *            http请求对象
	 * @return 返回Ajax应答实体对象
	 */
	@RequestMapping(value = "/deleteRmAuthorizeResourceRecord", produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> deleteRmAuthorizeResourceRecord(HttpServletRequest request) {
		boolean bLock = false;
		try {
			bLock = RequestConcurrentRoute.getSingleton().lock(request.getParameter(ISystemConstant.JSGUID));
			Map<String, Object> result = new HashMap<String, Object>();
			try {
				String party_id = request.getParameter("party_id");
				String bs_keyword = request.getParameter("bs_keyword");
				String[] authorize_resource_ids = request.getParameter("authorize_resource_ids").split(",");
				int count = iRmPartyService.deleteRm_authorize_resource_record(party_id, authorize_resource_ids);
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_SUCCESS);
				result.put(ISystemConstant.AJAX_MESSAGE, "删除用户成功!");
			} catch (Exception e) {
				result.put(ISystemConstant.AJAX_STATUS, ISystemConstant.AJAX_RESULT_FAIL);
				result.put(ISystemConstant.AJAX_MESSAGE, "删除用户失败!");
			}
			return result;
		} finally {
			// 最后解锁
			RequestConcurrentRoute.getSingleton().unLock(request.getParameter(ISystemConstant.JSGUID), bLock);
		}
	}
}
